home *** CD-ROM | disk | FTP | other *** search
- // arrayptr.cpp -- Show relationship between arrays and pointers
-
- //#include <stream.hpp>
- #include <iostream.h>
-
- #define MAX 10 // Size of array
-
- void showFirst(void);
-
- int array[MAX]; // Global array of MAX integers
-
- main()
- {
- array[0] = 123; // Assign value using indexing
- showFirst(); // Display value both ways
- *array = 321; // Assign value using pointer
- showFirst(); // Display value both ways
- }
-
- void showFirst(void)
- {
- cout << "array[0] = " << array[0] << '\n'; // Via index
- cout << "*array = " << *array << '\n'; // Via pointer
- }
-
-
- // Copyright (c) 1990 by Tom Swan. All rights reserved
- // Revision 1.00 Date: 08/31/1990 Time: 05:06 pm
-
- // Revision 1.01 Date: 07/03/1991 Time: 04:00 pm
- // Converted for Borland C++ 2.0
-
-